//package com.example.rbac.mq.rabbitMqConfig;
//
//import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
//import org.springframework.amqp.rabbit.connection.ConnectionFactory;
//import org.springframework.amqp.rabbit.core.RabbitTemplate;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.beans.factory.config.ConfigurableBeanFactory;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Scope;
//
////@Configuration
//public class CallBackConfig {
//    @Value("${spring.rabbitmq.host}")
//    private String addresses;
//
//    @Value("${spring.rabbitmq.port}")
//    private String port;
//
//    @Value("${spring.rabbitmq.username}")
//    private String username;
//
//    @Value("${spring.rabbitmq.password}")
//    private String password;
//
//    @Value("${spring.rabbitmq.virtual-host}")
//    private String virtualHost;
//
//    @Value("${spring.rabbitmq.publisher-confirms}")
//    private boolean publisherConfirms;
//
//    public ConnectionFactory  connectionFactory() {
//        CachingConnectionFactory  factory = new CachingConnectionFactory();
//        factory.setAddresses(addresses + ":" + port);
//        factory.setUsername(username);
//        factory.setPassword(password);
//        factory.setVirtualHost(virtualHost);
//        /** 如果要进行消息回调，则这里必须要设置为true */
//        factory.setPublisherConfirms(publisherConfirms);
//        return factory;
//    }
//    /** 因为要设置回调类，所以应是prototype类型，如果是singleton类型，则回调类为最后一次设置 */
//    @Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
//    public RabbitTemplate rabbitTemplate(){
//        RabbitTemplate template = new RabbitTemplate(connectionFactory());
//        return template;
//    }
//}
